A 4-component vector class, with floats.
More...
|
static float | distanceVec2 (const Vector &a, const Vector &b) |
|
static float | distanceVec3 (const Vector &a, const Vector &b) |
|
static float | distanceVec4 (const Vector &a, const Vector &b) |
|
static float | distanceSquaredVec2 (const Vector &a, const Vector &b) |
|
static float | distanceSquaredVec3 (const Vector &a, const Vector &b) |
|
static float | distanceSquaredVec4 (const Vector &a, const Vector &b) |
|
static float | dotVec2 (const Vector &a, const Vector &b) |
|
static float | dotVec3 (const Vector &a, const Vector &b) |
|
static float | dotVec4 (const Vector &a, const Vector &b) |
|
static Vector | crossVec3 (const Vector &a, const Vector &b) |
|
|
union { |
float _x |
|
float _r |
|
float x |
|
float r |
|
}; | |
| X or R component of the vector, accessible through different names.
|
|
union { |
float _y |
|
float _g |
|
float y |
|
float g |
|
}; | |
| Y or G component of the vector, accessible through different names.
|
|
union { |
float _z |
|
float _g |
|
float z |
|
float g |
|
}; | |
| Z or B component of the vector, accessible through different names.
|
|
union { |
float _w |
|
float _a |
|
float w |
|
float a |
|
}; | |
| W or A component of the vector, accessible through different names.
|
|
A 4-component vector class, with floats.
◆ Vector() [1/6]
nkMaths::Vector::Vector |
( |
| ) |
|
Default constructor. Defaults all components to 0.
◆ Vector() [2/6]
nkMaths::Vector::Vector |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
2D constructor.
- Parameters
-
x | The x component to assign. |
y | The y component to assign. |
◆ Vector() [3/6]
nkMaths::Vector::Vector |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
z |
|
) |
| |
3D constructor.
- Parameters
-
x | The x component to assign. |
y | The y component to assign. |
z | The z component to assign. |
◆ Vector() [4/6]
nkMaths::Vector::Vector |
( |
float |
x, |
|
|
float |
y, |
|
|
float |
z, |
|
|
float |
w |
|
) |
| |
4D constructor.
- Parameters
-
x | The x component to assign. |
y | The y component to assign. |
z | The z component to assign. |
w | The w component to assign. |
◆ Vector() [5/6]
nkMaths::Vector::Vector |
( |
const Vector & |
other | ) |
|
Copy constructor.
- Parameters
-
other | The vector to copy from. |
◆ Vector() [6/6]
nkMaths::Vector::Vector |
( |
const IntVector & |
other | ) |
|
Copy constructor.
- Parameters
-
other | The vector to copy from. |
◆ ~Vector()
nkMaths::Vector::~Vector |
( |
| ) |
|
◆ getX()
float nkMaths::Vector::getX |
( |
| ) |
const |
◆ getY()
float nkMaths::Vector::getY |
( |
| ) |
const |
◆ getZ()
float nkMaths::Vector::getZ |
( |
| ) |
const |
◆ getW()
float nkMaths::Vector::getW |
( |
| ) |
const |
◆ setX()
void nkMaths::Vector::setX |
( |
float |
value | ) |
|
Sets the x component.
- Parameters
-
◆ setY()
void nkMaths::Vector::setY |
( |
float |
value | ) |
|
Sets the y component.
- Parameters
-
◆ setZ()
void nkMaths::Vector::setZ |
( |
float |
value | ) |
|
Sets the z component.
- Parameters
-
◆ setW()
void nkMaths::Vector::setW |
( |
float |
value | ) |
|
Sets the w component.
- Parameters
-
◆ addX()
void nkMaths::Vector::addX |
( |
float |
value | ) |
|
Adds to the x component.
- Parameters
-
◆ addY()
void nkMaths::Vector::addY |
( |
float |
value | ) |
|
Adds to the y component.
- Parameters
-
◆ addZ()
void nkMaths::Vector::addZ |
( |
float |
value | ) |
|
Adds to the z component.
- Parameters
-
◆ addW()
void nkMaths::Vector::addW |
( |
float |
value | ) |
|
Adds to the w component.
- Parameters
-
◆ multX()
void nkMaths::Vector::multX |
( |
float |
value | ) |
|
Multiply the x component.
- Parameters
-
value | The value to multiply. |
◆ multY()
void nkMaths::Vector::multY |
( |
float |
value | ) |
|
Multiply the y component.
- Parameters
-
value | The value to multiply. |
◆ multZ()
void nkMaths::Vector::multZ |
( |
float |
value | ) |
|
Multiply the z component.
- Parameters
-
value | The value to multiply. |
◆ multW()
void nkMaths::Vector::multW |
( |
float |
value | ) |
|
Multiply the w component.
- Parameters
-
value | The value to multiply. |
◆ getLengthVec2()
float nkMaths::Vector::getLengthVec2 |
( |
| ) |
const |
- Returns
- The length of the vector, as if it was a 2D vector.
◆ getLengthVec3()
float nkMaths::Vector::getLengthVec3 |
( |
| ) |
const |
- Returns
- The length of the vector, as if it was a 3D vector.
◆ getLengthVec4()
float nkMaths::Vector::getLengthVec4 |
( |
| ) |
const |
- Returns
- The length of the vector, as if it was a 4D vector.
◆ getLengthSquaredVec2()
float nkMaths::Vector::getLengthSquaredVec2 |
( |
| ) |
const |
- Returns
- The squared length of the vector as if it was a 2D vector.
◆ getLengthSquaredVec3()
float nkMaths::Vector::getLengthSquaredVec3 |
( |
| ) |
const |
- Returns
- The squared length of the vector as if it was a 3D vector.
◆ getLengthSquaredVec4()
float nkMaths::Vector::getLengthSquaredVec4 |
( |
| ) |
const |
- Returns
- The squared length of the vector as if it was a 4D vector.
◆ getDistanceVec2()
float nkMaths::Vector::getDistanceVec2 |
( |
const Vector & |
other | ) |
const |
- Parameters
-
other | The vector to check the distance with. |
- Returns
- The distance between both vectors, as if they were 2D vectors.
◆ getDistanceVec3()
float nkMaths::Vector::getDistanceVec3 |
( |
const Vector & |
other | ) |
const |
- Parameters
-
other | The vector to check the distance with. |
- Returns
- The distance between both vectors, as if they were 3D vectors.
◆ getDistanceVec4()
float nkMaths::Vector::getDistanceVec4 |
( |
const Vector & |
other | ) |
const |
- Parameters
-
other | The vector to check the distance with. |
- Returns
- The distance between both vectors, as if they were 4D vectors.
◆ getDistanceSquaredVec2()
float nkMaths::Vector::getDistanceSquaredVec2 |
( |
const Vector & |
other | ) |
const |
- Parameters
-
other | The vector to check the distance with. |
- Returns
- The squared distance between both vectors, as if they were 2D vectors.
◆ getDistanceSquaredVec3()
float nkMaths::Vector::getDistanceSquaredVec3 |
( |
const Vector & |
other | ) |
const |
- Parameters
-
other | The vector to check the distance with. |
- Returns
- The squared distance between both vectors, as if they were 3D vectors.
◆ getDistanceSquaredVec4()
float nkMaths::Vector::getDistanceSquaredVec4 |
( |
const Vector & |
other | ) |
const |
- Parameters
-
other | The vector to check the distance with. |
- Returns
- The squared distance between both vectors, as if they were 4D vectors.
◆ normalizeVec2()
void nkMaths::Vector::normalizeVec2 |
( |
| ) |
|
Normalizes the vector, interpreting it as a 2D vector.
◆ normalizeVec3()
void nkMaths::Vector::normalizeVec3 |
( |
| ) |
|
Normalizes the vector, interpreting it as a 3D vector.
◆ normalizeVec4()
void nkMaths::Vector::normalizeVec4 |
( |
| ) |
|
Normalizes the vector, interpreting it as a 4D vector.
◆ getNormalizedVec2()
Vector nkMaths::Vector::getNormalizedVec2 |
( |
| ) |
const |
- Returns
- A vector corresponding to this vector interpreted as a 2D vector and normalized.
◆ getNormalizedVec3()
Vector nkMaths::Vector::getNormalizedVec3 |
( |
| ) |
const |
- Returns
- A vector corresponding to this vector interpreted as a 3D vector and normalized.
◆ getNormalizedVec4()
Vector nkMaths::Vector::getNormalizedVec4 |
( |
| ) |
const |
- Returns
- A vector corresponding to this vector interpreted as a 4D vector and normalized.
◆ dotProductVec2()
float nkMaths::Vector::dotProductVec2 |
( |
const Vector & |
other | ) |
const |
Computes the dot product, interpreting both vectors as 2D vectors.
- Parameters
-
other | The vector to compute the product with. |
- Returns
- The resulting dot product computed.
◆ dotProductVec3()
float nkMaths::Vector::dotProductVec3 |
( |
const Vector & |
other | ) |
const |
Computes the dot product, interpreting both vectors as 3D vectors.
- Parameters
-
other | The vector to compute the product with. |
- Returns
- The resulting dot product computed.
◆ dotProductVec4()
float nkMaths::Vector::dotProductVec4 |
( |
const Vector & |
other | ) |
const |
Computes the dot product, interpreting both vectors as 4D vectors.
- Parameters
-
other | The vector to compute the product with. |
- Returns
- The resulting dot product computed.
◆ setAsCrossVec3()
void nkMaths::Vector::setAsCrossVec3 |
( |
const Vector & |
other | ) |
|
Computes and sets in place the cross product, interpreting both vectors as 3D vectors.
- Parameters
-
other | The vector to compute the product with. |
◆ getCrossVec3()
Vector nkMaths::Vector::getCrossVec3 |
( |
const Vector & |
other | ) |
const |
Computes the cross product, interpreting both vectors as 3D vectors.
- Parameters
-
other | The vector to compute the product with. |
- Returns
- The resulting cross product computed.
◆ fromString()
Parse components from a string. Format is "x,y,z,w".
- Parameters
-
◆ operator=() [1/2]
Assignment operator.
- Parameters
-
other | The vector to overwrite from. |
- Returns
- The calling vector, updated.
◆ operator=() [2/2]
Assignment operator.
- Parameters
-
other | The vector to overwrite from. |
- Returns
- The calling vector, updated.
◆ operator+()
Vector nkMaths::Vector::operator+ |
( |
const Vector & |
other | ) |
const |
Addition operator.
- Parameters
-
other | The vector to operate with. |
- Returns
- A result vector, after operation application.
◆ operator+=()
void nkMaths::Vector::operator+= |
( |
const Vector & |
other | ) |
|
Addition and assignment operator.
- Parameters
-
other | The vector to operate with. |
◆ operator-()
Vector nkMaths::Vector::operator- |
( |
const Vector & |
other | ) |
const |
Subtraction operator.
- Parameters
-
other | The vector to operate with. |
- Returns
- A result vector, after operation application.
◆ operator-=()
void nkMaths::Vector::operator-= |
( |
const Vector & |
other | ) |
|
Subtraction and assignment operator.
- Parameters
-
other | The vector to operate with. |
◆ operator*() [1/4]
Vector nkMaths::Vector::operator* |
( |
const Vector & |
other | ) |
const |
Multiplication operator.
- Parameters
-
other | The vector to operate with. |
- Returns
- A result vector, after operation application.
◆ operator*=() [1/4]
void nkMaths::Vector::operator*= |
( |
const Vector & |
other | ) |
|
Multiplication and assignment operator.
- Parameters
-
other | The vector to operate with. |
◆ operator*() [2/4]
Multiplication operator.
- Parameters
-
other | The quaternion to operate with. |
- Returns
- A result vector, after transformation.
◆ operator*=() [2/4]
void nkMaths::Vector::operator*= |
( |
const Quaternion & |
other | ) |
|
Multiplication and assignment operator.
- Parameters
-
other | The quaternion to operate with. |
◆ operator*() [3/4]
Vector nkMaths::Vector::operator* |
( |
const Matrix & |
mat | ) |
const |
Multiplication operator.
- Parameters
-
mat | The matrix to operate with. |
- Returns
- A result vector, after transformation.
◆ operator*=() [3/4]
void nkMaths::Vector::operator*= |
( |
const Matrix & |
other | ) |
|
Multiplication and assignment operator.
- Parameters
-
other | The matrix to operate with. |
◆ operator*() [4/4]
Vector nkMaths::Vector::operator* |
( |
float |
coeff | ) |
const |
Multiplication operator.
- Parameters
-
coeff | The scalar to operate with. |
- Returns
- A result vector, after operation application on all components.
◆ operator*=() [4/4]
void nkMaths::Vector::operator*= |
( |
float |
coeff | ) |
|
Multiplication and assignment operator.
- Parameters
-
coeff | The scalar to operate with. |
◆ operator/() [1/2]
Vector nkMaths::Vector::operator/ |
( |
const Vector & |
other | ) |
const |
Division operator.
- Parameters
-
other | The vector to operate with. |
- Returns
- A result vector, after operation application.
◆ operator/=() [1/2]
void nkMaths::Vector::operator/= |
( |
const Vector & |
other | ) |
|
Division and assignment operator.
- Parameters
-
other | The vector to operate with. |
◆ operator/() [2/2]
Vector nkMaths::Vector::operator/ |
( |
float |
coeff | ) |
const |
Division operator.
- Parameters
-
coeff | The scalar to operate with. |
- Returns
- A result vector, after operation application on all components.
◆ operator/=() [2/2]
void nkMaths::Vector::operator/= |
( |
float |
coeff | ) |
|
Division and assignment operator.
- Parameters
-
coeff | The scalar to operate with. |
◆ operator==()
bool nkMaths::Vector::operator== |
( |
const Vector & |
other | ) |
const |
Equality operator.
- Parameters
-
other | The vector to check against. |
- Returns
- If the vectors are equal (true) or not (false).
◆ operator!=()
bool nkMaths::Vector::operator!= |
( |
const Vector & |
other | ) |
const |
Difference operator.
- Parameters
-
other | The vector to check against. |
- Returns
- If the vectors are different (true) or not (false).
◆ operator<()
bool nkMaths::Vector::operator< |
( |
const Vector & |
other | ) |
const |
Less than operator.
- Parameters
-
other | The vector to check against. |
- Returns
- If the calling vector is smaller (true) or not (false).
◆ operator<=()
bool nkMaths::Vector::operator<= |
( |
const Vector & |
other | ) |
const |
Less than or equal operator.
- Parameters
-
other | The vector to check against. |
- Returns
- If the calling vector is smaller, equal (true) or not (false).
◆ operator>()
bool nkMaths::Vector::operator> |
( |
const Vector & |
other | ) |
const |
Greater than operator.
- Parameters
-
other | The vector to check against. |
- Returns
- If the calling vector is greater (true) or not (false).
◆ operator>=()
bool nkMaths::Vector::operator>= |
( |
const Vector & |
other | ) |
const |
Greater than or equal operator.
- Parameters
-
other | The vector to check against. |
- Returns
- If the calling vector is greater, equal (true) or not (false).
◆ distanceVec2()
static float nkMaths::Vector::distanceVec2 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.getDistanceVec2(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ distanceVec3()
static float nkMaths::Vector::distanceVec3 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.getDistanceVec3(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ distanceVec4()
static float nkMaths::Vector::distanceVec4 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.getDistanceVec4(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ distanceSquaredVec2()
static float nkMaths::Vector::distanceSquaredVec2 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.getDistanceSquaredVec2(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ distanceSquaredVec3()
static float nkMaths::Vector::distanceSquaredVec3 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.getDistanceSquaredVec3(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ distanceSquaredVec4()
static float nkMaths::Vector::distanceSquaredVec4 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.getDistanceSquaredVec4(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ dotVec2()
static float nkMaths::Vector::dotVec2 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.dotProductVec2(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ dotVec3()
static float nkMaths::Vector::dotVec3 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.dotProductVec3(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ dotVec4()
static float nkMaths::Vector::dotVec4 |
( |
const Vector & |
a, |
|
|
const Vector & |
b |
|
) |
| |
|
static |
Static version for a.dotProductVec3(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
◆ crossVec3()
Static version for a.getCrossVec3(b).
- Parameters
-
a | The left operand. |
b | The right operand. |
- Returns
- The result of the operation.
The documentation for this class was generated from the following file:
- Documentation/Headers/NilkinsMaths/Algebra/Vector.h